#define _CRT_SECURE_NO_WARNINGS 1


#include<stdio.h>
#include<string.h>
#include<stdlib.h>

char* Func(char* str1, char* str2)
{
	int len1 = strlen(str1);
	int len2 = strlen(str2);
	char* str_ret = (char*)malloc(sizeof(char) * len1);
	int temp = strlen(str1);
	char** arr = (char**)malloc(sizeof(char*) * 100);
	int count[100] = { 0 };
	int index = 0;

	for (int i = 0; i < 100; i++)
	{
		arr[i] = (char*)malloc(sizeof(char) * len1);
	}

	for (int i = 0; i < len1; i++)
	{
		int x = temp;
		while (x)
		{
			strncpy(str_ret, str1 + i, x);
			str_ret[x] = '\0';
			if (strstr(str2, str_ret))
			{
				strcpy(arr[index], str_ret);
				count[index++] = strlen(str_ret);
			}
			x--;
		}
		x--;
	}

	int max = 0;
	for (int i = 0; i < index; i++)
	{
		if (count[i] > count[max])
		{
			max = i;
		}
	}

	return count[max] != 0 ? arr[max] : NULL;
}

int main()
{
	char str1[] = "adbccadebbca", str2[] = "edabccadece";
	printf("%s\n", Func(str1, str2));

	return 0;
}